function editInfo(obj) {    
    var tds= $(obj).parent().parent().find('td');
    $('#mdyId').val(tds.eq(0).text());
    $('#mdyname').val(tds.eq(1).text());
    $('#mdysex').val(tds.eq(2).text());
    $('#mdyage').val(tds.eq(3).text());
    $('#mdyidentify').val(tds.eq(4).text());
    $('#mdyphone').val(tds.eq(5).text());
    $('#mdyemail').val(tds.eq(6).text());
    $('#mdyaddr').val(tds.eq(7).text());

    var sex = tds.eq(2).text();
    if (sex == '0') {
        document.getElementById('mdysexwomen').checked = true;    
    } else {    
        document.getElementById('mdysexman').checked = true;    
    }
    $('#modifyModal').modal('show');   
}    
//提交更改    
function update() {    
    //获取模态框数据
    var id = $('#mdyId').val();
    var name = $('#mdyname').val();        
    var sex = $('input:radio[name="sex"]:checked').val();
    var age = $('#mdyage').val();
    var idy = $('#mdyidentify').val();
    var phone=$('#mdyphone').val();
    var addr = $('#mdyaddr').val();
    var email = $('#mdyemail').val();

    var str= '{"id":"'+id+'","name":"'+ name+ '", "sex":"' + sex +'", "age":"' + age  + '", "phone":"' + phone
        + '", "identify":"' + idy +  '", "address":"' + addr +'", "email":"' + email +'" }';
    console.log(str);
    $.ajax({    
        type: "post",    
        url: "http://localhost:8066/Emp/updateByPrimaryKeySelective",
        data: str,
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        success: function(result) {
            console.log(result);
            location.reload();
        },
        error:function (err) {                                  //请求失败调用
            console.log(err);
            console.log("请求错误");
        }
    });   
    $('#modifyModal').modal('hide');    
}
$(document).ready(function(){

    $('#submitadd').click(function(){
        var name = $('#addname').val();
        var sex = $('input:radio[name="addsex"]:checked').val();
        var age = $('#addage').val();
        var idy = $('#addposition').val();
        var phone=$('#addphone').val();
        var addr = $('#addaddr').val();
        var email = $('#addemail').val();

        var st= '{"name":"'+ name+ '", "sex":"' + sex +'", "age":"' + age  + '", "phone":"' + phone
            + '", "identify":"' + idy +  '", "address":"' + addr +'", "email":"' + email +'" }';

        $.ajax({
            type: 'post',
            url: 'http://localhost:8066/Emp/insert',
            data:st,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            success: function(result) {
                    console.log(result);
                    location.reload();
            }
        });
        $('#addModal').modal('hide');

    });
});
